# -*- encoding: utf-8 -*-

class Mul (object):

    """ Classe définissant une instruction MUL Ra, Rb, Rc. """

    def __init__ (self, ra,rb,rc, mem):
        self.__ra = ra
        self.__rb = rb
        self.__rc = rc
        self.__mem = mem

    def do (self):
        self.__mem.setRegister(
            num = self.__ra,
            newVal = (self.__mem.getRegister(self.__rb) * self.__mem.getRegister(self.__rc))%256
            )

    def __str__ (self):
        return "mul r{0:d} r{1:d} r{2:d}".format(self.__ra, self.__rb, self.__rc) 

    def __unicode__ (self):
        return self.__str__ () 

class MulV (object):

    """ Classe définissant une instruction Mul Ra, Rb, Val. """

    def __init__ (self, ra, rb, val, mem):
        self.__ra = ra 
        self.__rb = rb
        self.__val = val
        self.__mem = mem

    def do (self):
        self.__mem.setRegister(
            num = self.__ra,
            newVal = self.__mem.getRegister(self.__rb) * self.__val
            )

    def __str__ (self):
        return "mul r{0:d} r{1:d} #{2:d}".format(self.__ra, self.__rb, self.__val)

    def __unicode__ (self):
        return str(self)
